package weeny.pre.renderer;

import java.awt.Shape;
import java.awt.geom.AffineTransform;

import prefuse.render.ShapeRenderer;
import prefuse.visual.VisualItem;

public class DataShapeRenderer extends ShapeRenderer{
	public static final String SHAPE_FIELD = "shape_field";
	
	private String field = SHAPE_FIELD;
	private AffineTransform transform = new AffineTransform();
	
	public DataShapeRenderer() {
		
	}
	
	public DataShapeRenderer(String field) {
		this.field = field;
	}
	
	protected Shape getRawShape(VisualItem item) {
		if (!item.canGet(field, Shape.class)){
			return null;
		}
		return (Shape) item.get(field);
	}
	
	@Override
	protected AffineTransform getTransform(VisualItem item) {
		transform.setToTranslation(item.getX(), item.getY());
		return transform;
	}
}